<?php
/* SVN FILE: $Id: item_multipleeffect.php 247 2009-10-22 15:31:39Z supersmashbrothers $ */
/**
* ibMarket 2
* IP.Board 3.0
* Multiple Name Effect item
*
* @author $Author: supersmashbrothers $
* @copyright $Copyright$
* @version $Revision: 247 $
* @lastrevision $Date: 2009-10-22 15:31:39 +0000 (Thu, 22 Oct 2009) $
* @modifiedby $LastChangedBy: supersmashbrothers $
* @lastmodified $LastChangedDate: 2009-10-22 15:31:39 +0000 (Thu, 22 Oct 2009) $
* @filesource $URL: http://ipb-ibmarket.googlecode.com/svn/ibmarket2/trunk/admin/applications_addon/other/ibmarket/items/own/item_multipleeffect.php $
*/

class item_multipleeffect extends templateItem
{
	/**
	 * The default name of the item
	 *
	 * @access	protected
	 * @var		string
	 */
	protected $defaultName = "Multiple Name Effect";
	
	/**
	 * The default description of the item
	 *
	 * @access	protected
	 * @var		string
	 */
	protected $defaultDescription = "Add an effect to your name with an addition to others.";
	
	// Inherited Properties
	/**
	 * Item setting to allow multiple instances within ibMarket 
	 *
	 * @access	protected
	 * @var		boolean
	 */
	protected $allowMultiple = true;
	
	/**
	 * Item specific setting
	 *
	 * @access	protected
	 * @var		array
	 */
	protected $itemSettings = array();
	
	/**
	 * Constructor to setup the item
	 *
	 * @access	public
	 * @param	ipsRegistry	$registry	IPB registry
	 * @param	array		&$item		The item information
	 */
	public function __construct(ipsRegistry $registry, array &$item)
	{
		parent::__construct($registry, $item);
		
		if($item['item_config'] || $item['item_id'] != 0)
		{
			$this->itemSettings = unserialize($item['item_config']);
		}
		else
		{
			$this->itemSettings['effect'] = 'italics';
			$this->itemSettings['add_remove'] = 'add';
		}
	}
	
	/**
	 * Additional settings when adding/editing the item
	 *
	 * @access	public
	 * @return	string|bool	string if there is something to edit, false otherwise
	 */
	public function adminForm()
	{
		$effects = array();
		$effects[] = array('bold',			$this->lang->words['effect_bold']);
		$effects[] = array('italics',		$this->lang->words['effect_italics']);
		$effects[] = array('color',			$this->lang->words['effect_color']);
		$effects[] = array('background',	$this->lang->words['effect_bgcolor']);
		$effects[] = array('dropshadow',	$this->lang->words['effect_dshadow']);
		$effects[] = array('shadow',		$this->lang->words['effect_shadow']);
		$effects[] = array('glow',			$this->lang->words['effect_glow']);
		$effects[] = array('blur',			$this->lang->words['effect_blur']);
		$effects[] = array('flipv',			$this->lang->words['effect_vflip']);
		$effects[] = array('fliph',			$this->lang->words['effect_hflip']);
		$effects[] = array('wave',			$this->lang->words['effect_wave']);
		$effects[] = array('xray',			$this->lang->words['effect_xray']);
		$effects[] = array('invert',		$this->lang->words['effect_invert']);
		
		$action = array(array('add',$this->lang->words['add_effect']),array('remove',$this->lang->words['remove_effect']));
		
		$form['effect'] = ipsRegistry::getClass('output')->formDropdown('item[effect]', $effects, $this->itemSettings['effect']);
		$form['add_remove'] = ipsRegistry::getClass('output')->formDropdown('item[add_remove]', $action, $this->itemSettings['add_remove']);
		return <<<EOF
				<li>
					<span style='font-weight:bold'>{$this->lang->words['effect_bold']}</span>
					<br />
					<span style='font-style:italic'>{$this->lang->words['effect_italics']}</span>
					<br />
					<span style='color:#FF00FF'>{$this->lang->words['effect_color']}</span>
					<br />
					<span style='background-color:#00FFFF'>{$this->lang->words['effect_bgcolor']}</span>
					<br />
					<span style='display:inline-block; filter: dropshadow(color=#0000FF, offx=5, offy=-3, Positive=1)'>{$this->lang->words['effect_dshadow']}</span>
					<br />
					<span style='display:inline-block; filter: shadow(color=#FF0000, direction=45)'>{$this->lang->words['effect_shadow']}</span>
					<br />
					<span style='display:inline-block; filter: glow(color=#00FF00, strength=6)'>{$this->lang->words['effect_glow']}</span>
					<br />
					<span style='display:inline-block; filter: blur(add=false, direction=140, strength=6)'>{$this->lang->words['effect_blur']}</span>
					<br />
					<span style='display:inline-block; filter: flipv'>{$this->lang->words['effect_vflip']}</span>
					<br />
					<span style='display:inline-block; filter: fliph'>{$this->lang->words['effect_hflip']}</span>
					<br />
					<span style='display:inline-block; filter: wave(strength=2)'>{$this->lang->words['effect_wave']}</span>
					<br />
					<span style='display:inline-block; filter: xray'>{$this->lang->words['effect_xray']}</span>
					<br />
					<span style='display:inline-block; filter: invert'>{$this->lang->words['effect_invert']}</span>
				</li>
				<li>
					<label>
						{$this->lang->words['which_effect']}
					</label>
					{$form['effect']}
				</li>
				<li>
					<label>
						{$this->lang->words['action_effect']}
					</label>
					{$form['add_remove']}
				</li>

EOF;
	}
	
	/**
	 * Saving to adding/editing the item
	 *
	 * @access	public
	 * @param	array	&$item_info		The new item information to be stored in the database.
	 * @param	array	[$input]		Relavent input relating to the item
	 * @todo
	 * @return	void
	 */
	public function adminSave(array &$item_info, array $input)
	{
		$setting = array();
		$setting['effect'] = $input['effect'];
		$setting['add_remove'] = $input['add_remove'];
		
		$item_info['item_config'] = serialize($setting);
		
		if($this->DB->checkForField("multiple_effect", "profile_portal"))
		{
			$this->DB->changeField("profile_portal","multiple_effect","multiple_effect","TEXT NOT NULL","''");
		}
		else
		{
			$this->DB->addField("profile_portal","multiple_effect","TEXT NOT NULL","''");
		}
	}
	
	/**
	 * When quick saving the price and stock
	 *
	 * @access	public
	 * @param	array	&$item_info		The new item information to be stored in the database.
	 * @param	string	$type			Possible values: 'stockprice', more possibly in the future
	 * @return	void
	 */
	public function adminQuickSave(array &$item_info, $type)
	{
		return;
	}
	
	/**
	 * When removing the item from ibMarket
	 *
	 * @access	public
	 * @return	void
	 */
	public function adminRemove()
	{
		if(count(marketRegistry::getItemsByFiles($this->item['filename'])) == 1)
		{
			$this->DB->dropField("profile_portal","multiple_effect");
		}
	}
	
	/**
	 * Viewing the file edits if any
	 *
	 * @access	public
	 * @return	string|bool	string if there is something to edit, false otherwise
	 */
	public function adminViewFileEdits()
	{
		$adminDir = CP_DIRECTORY;
		$edits = array();
		$edits['topics.php']['line'] = sprintf($this->lang->words['about_the_line_x'],2189);
		$edits['threaded.php']['line'] = sprintf($this->lang->words['about_the_line_x'],260);
		
		return <<<EOF
<div id='skinEditsGlobal'>
	<div class='acp-box'>
		<h3>
			{$this->lang->words['skin_template']}: {$this->lang->words['bit_skin_topic']}
		</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th colspan='2'>topicViewTemplate</th>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['add_beginning']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="10"><php>
if(!class_exists('multipleEffects'))
{
	require_once( IPSLib::getAppDir('ibmarket')."/sources/multipleEffects.php");
}
</php>
</textarea>
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['find']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="1">{\$post['author']['members_display_name']}</textarea>
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['add_before']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="10">{parse expression="multipleEffects::getPrefix(unserialize(\$post['author']['multiple_effect']))"}</textarea>
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['add_after']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="10">{parse expression="multipleEffects::getSuffix(unserialize(\$post['author']['multiple_effect']))"}</textarea>
				</td>
			</tr>
			<tr>
				<td style='white-space:nowrap;width:1px;min-width:1%'>
					{$this->lang->words['it_will_look_like']}
				</td>
				<td>
					<textarea style="width: 98%;" cols="80" rows="10">{parse expression="multipleEffects::getPrefix(unserialize(\$post['author']['multiple_effect']))"}{\$post['author']['members_display_name']}{parse expression="multipleEffects::getPrefix(unserialize(\$post['author']['multiple_effect']))"}</textarea>
				</td>
			</tr>
		</table>
	</div>
</div>
EOF;
	}
	
	/**
	 * Any admin AJAX functionality
	 *
	 * @access	public
	 * @param	array	$invItem		The inventory item
	 * @return	void
	 */
	public function adminAjax()
	{
		return;
	}
	
	/**
	 * Check and modify the intentory item information before storing in the database
	 *
	 * @access	public
	 * @param	array	&$invItem		The new inventory item information to be stored in the database.
	 * @return	bool	true if the item is successfully created, false otherwise
	 */
	public function publicOnCreateItem(array &$invItem)
	{
		return true;
	}
	
	/**
	 * When using the item
	 * Show a form and validate the form
	 *
	 * @access	public
	 * @param	array	$invItem		The inventory item
	 * @return	string|bool				string if there is a form to be used, true if successfully used, false otherwise
	 */
	public function publicUseItem(array &$invItem)
	{
		$this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_items' ) );
		
		$effect = $this->memberData['multiple_effect'] ? unserialize($this->memberData['multiple_effect']) : array();
		$effect = is_array($effect) ? $effect : array();
		
		if($this->request['request_method'] == 'post')
		{
			unset($effect[$this->itemSettings['effect']]);
			if($this->itemSettings['add_remove'] == 'add')
			{
				$effect[$this->itemSettings['effect']] = array();
				if(!in_array($this->itemSettings['effect'],array('bold','italics','blur','flipv','fliph','wave','xray','invert')))
				{
					$effect[$this->itemSettings['effect']]['color'] = $this->request['color'];
				}
				if(in_array($this->itemSettings['effect'],array('blur','wave','glow')))
				{
					$effect[$this->itemSettings['effect']]['strength'] = max(intval($this->request['strength']),0);
				}
				if(in_array($this->itemSettings['effect'],array('blur','shadow')))
				{
					$effect[$this->itemSettings['effect']]['direction'] = intval($this->request['direction']) % 360;
				}
				if($this->itemSettings['effect'] == 'blur')
				{
					$effect[$this->itemSettings['effect']]['show_text'] = isset($this->request['show_text']) && $this->request['show_text'];
				}
				if($this->itemSettings['effect'] == 'dropshadow')
				{
					$effect[$this->itemSettings['effect']]['offx'] = intval($this->request['x_offset']);
					$effect[$this->itemSettings['effect']]['offy'] = intval($this->request['y_offset']);
					$effect[$this->itemSettings['effect']]['drop_background'] = !isset($this->request['drop_background']) || !$this->request['drop_background'];
				}
			}
			
			IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'multiple_effect' => serialize($effect) ) ) );
			
			$this->deleteItems($invItem);
			
			$this->writeLog($invItem, "Applied multiple name effect on ".$this->memberData['members_display_name']);
			
			$this->registry->getClass('output')->redirectScreen( $this->lang->words['name_effect_applied'], $this->settings['base_url_with_app'] . "module=inventory" );
		}
		
		require_once( IPSLib::getAppDir('ibmarket')."/sources/multipleEffects.php");
		
		if(!$effect[$this->itemSettings['effect']])
		{
			$effect[$this->itemSettings['effect']] = array();
			if(!in_array($this->itemSettings['effect'],array('bold','italics','blur','flipv','fliph','wave','xray','invert')))
			{
				$effect[$this->itemSettings['effect']]['color'] = "#FFFFFF";
			}
			if(in_array($this->itemSettings['effect'],array('blur','wave','glow')))
			{
				$effect[$this->itemSettings['effect']]['strength'] = 2;
			}
			if(in_array($this->itemSettings['effect'],array('blur','shadow')))
			{
				$effect[$this->itemSettings['effect']]['direction'] = 120;
			}
			if($this->itemSettings['effect'] == 'blur')
			{
				$effect[$this->itemSettings['effect']]['show_text'] = true;
			}
			if($this->itemSettings['effect'] == 'dropshadow')
			{
				$effect[$this->itemSettings['effect']]['offx'] = 5;
				$effect[$this->itemSettings['effect']]['offy'] = -3;
				$effect[$this->itemSettings['effect']]['drop_background'] = false;
			}
		}
		$editing = array($this->itemSettings['effect'] => $effect[$this->itemSettings['effect']]);
		unset($effect[$this->itemSettings['effect']]);
		$_prefix = multipleEffects::getPrefix($effect);
		$_suffix = multipleEffects::getSuffix($effect);
		if($this->itemSettings['add_remove'] == 'add')
		{
			if($this->itemSettings['effect'] == 'bold')
			{
				$prefix .= "<span id='currentEffect' style=\"font-weight:bold\">";
			}
			elseif($this->itemSettings['effect'] == 'italics')
			{
				$prefix .= "<span id='currentEffect' style=\"font-style:italic\">";
			}
			elseif($this->itemSettings['effect'] == 'color')
			{
				$prefix .= "<span id='currentEffect' style=\"color:{$editing[$this->itemSettings['effect']]['color']}\">";
			}
			elseif($this->itemSettings['effect'] == 'background')
			{
				$prefix .= "<span id='currentEffect' style=\"background-color:{$editing[$this->itemSettings['effect']]['color']}\">";
			}
			elseif($this->itemSettings['effect'] == 'dropshadow')
			{
				$prefix .= "<span id='currentEffect' style=\"display:inline-block; filter:dropshadow(color={$editing[$this->itemSettings['effect']]['color']}, offx={$editing[$this->itemSettings['effect']]['offx']}, offy={$editing[$this->itemSettings['effect']]['offy']}, Positive=".($editing[$this->itemSettings['effect']]['drop_background'] ? 'true' : 'false').")\">";
			}
			elseif($this->itemSettings['effect'] == 'shadow')
			{
				$prefix .= "<span id='currentEffect' style=\"display:inline-block; filter:shadow(color={$editing[$this->itemSettings['effect']]['color']}, direction={$editing[$this->itemSettings['effect']]['direction']})\">";
			}
			elseif($this->itemSettings['effect'] == 'glow')
			{
				$prefix .= "<span id='currentEffect' style=\"display:inline-block; filter:glow(color={$editing[$this->itemSettings['effect']]['color']}, strength={$editing[$this->itemSettings['effect']]['strength']})\">";
			}
			elseif($this->itemSettings['effect'] == 'blur')
			{
				$prefix .= "<span id='currentEffect' style=\"display:inline-block; filter:blur(add=".($editing[$this->itemSettings['effect']]['show_text'] ? 'true' : 'false').", direction={$editing['direction']}, strength={$editing['strength']})\">";
			}
			elseif($this->itemSettings['effect'] == 'flipv')
			{
				$prefix .= "<span id='currentEffect' style=\"display:inline-block; filter:flipv\">";
			}
			elseif($this->itemSettings['effect'] == 'fliph')
			{
				$prefix .= "<span id='currentEffect' style=\"display:inline-block; filter:fliph\">";
			}
			elseif($this->itemSettings['effect'] == 'wave')
			{
				$prefix .= "<span id='currentEffect' style=\"display:inline-block; filter:wave(strength={$editing[$this->itemSettings['effect']]['strength']})\">";
			}
			elseif($this->itemSettings['effect'] == 'xray')
			{
				$prefix .= "<span id='currentEffect' style=\"display:inline-block; filter:xray\">";
			}
			elseif($this->itemSettings['effect'] == 'invert')
			{
				$prefix .= "<span id='currentEffect' style=\"display:inline-block; filter:invert\">";
			}
			$suffix = "</span>";
		}
		
		$html = <<<EOF
<form id='multipleEffectForm' method="post" action="{$this->settings['base_url_with_app']}module=inventory&amp;section=item&amp;item={$invItem['i_id']}">
	<div id='multipleEffect'class='block_wrap'>
		<h3 id='multipleEffectHeader' class='maintitle'>{$this->item['item_name']}</h3>

EOF;
		if($this->itemSettings['add_remove'] == 'add' && !in_array($this->itemSettings['effect'],array('bold','italics','blur','flipv','fliph','wave','xray','invert')))
		{
			$cmap = array();
			
			for($b = 0; $b < 16; $b++)
			{
				for($g = 0; $g < 16; $g++)
				{
					for($r = 0; $r < 16; $r++)
					{
						$cmap[floor($b/4)] .= "					<area shape='rect' coords='".($g*4+$b%4*64).",".($r*6).",".($g*4+$b%4*64+3).",".($r*6+5)."' class='mapSection' id='".strtoupper(($r == 0 ? "00" : dechex($r*17)).($g == 0 ? "00" : dechex($g*17)).($b == 0 ? "00" : dechex($b*17)))."'>\n";
					}
				}
			}
			$html .= <<<EOF
		<fieldset class="row1">
			<div class='short'>
				<strong>{$this->lang->words['choose_color']}</strong>
			</div>
			<div class='short' id='colorMap'>
				<map name='colormap1' id='colorMap1' class='colorMap'>
{$cmap[0]}
				</map>
				<map name='colormap2' id='colorMap2' class='colorMap'>
{$cmap[1]}
				</map>
				<map name='colormap3' id='colorMap3' class='colorMap'>
{$cmap[2]}
				</map>
				<map name='colormap4' id='colorMap4' class='colorMap'>
{$cmap[3]}
				</map>
				<img usemap='#colormap1' src='{$this->settings['market_images_url']}/color_table-1.png' border='0' /><img usemap='#colormap2' src='{$this->settings['market_images_url']}/color_table-2.png' border='0' />
				<br />
				<img usemap='#colormap3' src='{$this->settings['market_images_url']}/color_table-3.png' border='0' /><img usemap='#colormap4' src='{$this->settings['market_images_url']}/color_table-4.png' border='0' />
				<br />
				<br />
				{$this->lang->words['hex_code']}: <input type='text' id='previewHexColor' value='' class='input_text' /> <input type='button' value='{$this->lang->words['preview']}' class='input_text' id='previewColorButton' />
			</div>
		</fieldset>
<script type='text/javascript'>
$$('.mapSection').each(function(area) {
	area.observe('mouseover',function(event){
		$('previewHexColor').setValue("#"+event.element().identify());
	});
	area.observe('click',function(event){
		$('color').setValue("#"+event.element().identify());
		updateEffect();
	});
});
$('previewColorButton').observe('click',function(){
	$('color').setValue($('previewHexColor').getValue());
	updateEffect();
});
</script>

EOF;
		}
		$html .= <<<EOF
		<fieldset class="row2">
			<ul>

EOF;
		if($this->itemSettings['add_remove'] == 'add' && !in_array($this->itemSettings['effect'],array('bold','italics','blur','flipv','fliph','wave','xray','invert')))
		{
			$html .= <<<EOF
				<li>
					<label><strong>{$this->lang->words['color_preview']}</strong></label>
					<input type='text' name='color' id='color' value='{$editing[$this->itemSettings['effect']]['color']}' class='input_text' />
				</li>

EOF;
		}
		if($this->itemSettings['add_remove'] == 'add' && in_array($this->itemSettings['effect'],array('blur','wave','glow')))
		{
			$html .= <<<EOF
				<li>
					<label><strong>{$this->lang->words['change_strength']}</strong></label>
					<input type='button' value='+' id='strength+' class='input_submit' />
					<input type='button' value='-' id='strength-' class='input_submit' />
					<input type='hidden' name='strength' id='strength' value='{$editing[$this->itemSettings['effect']]['strength']}' />
<script type='text/javascript'>
$('strength+').observe('click',function(){
	$('strength').setValue(parseInt($('strength').getValue()) + 1);
	updateEffect();
});
$('strength-').observe('click',function(){
	$('strength').setValue(Math.max(parseInt($('strength').getValue()) - 1, 0));
	updateEffect();
});
</script>
				</li>

EOF;
		}
		if($this->itemSettings['add_remove'] == 'add' && in_array($this->itemSettings['effect'],array('blur','shadow')))
		{
			$html .= <<<EOF
				<li>
					<label><strong>{$this->lang->words['change_direction']}</strong></label>
					<span style="display:inline-block">
						<input type='button' value='{$this->lang->words['rotate_clockwise']}' id='directionRight' class='input_submit' />
						<input type='button' value='{$this->lang->words['rotate_counter_clockwise']}' id='directionLeft' class='input_submit' />
						<br />
						<input type='text' id='direction' name='direction' value='{$editing[$this->itemSettings['effect']]['direction']}' class='input_text' />&deg;
					</span>
<script type='text/javascript'>
$('directionRight').observe('click',function(){
	$('direction').setValue((parseInt($('direction').getValue()) + 1) % 360);
	updateEffect();
});
$('directionLeft').observe('click',function(){
	$('direction').setValue((parseInt($('direction').getValue()) - 1) % 360);
	updateEffect();
});
</script>
				</li>

EOF;
		}
		if($this->itemSettings['add_remove'] == 'add' && $this->itemSettings['effect'] =='blur')
		{
			$checked = $editing[$this->itemSettings['effect']]['show_text'] ? "checked='checked' " : "";
			$html .= <<<EOF
				<li>
					<label><strong>{$this->lang->words['show_unblur_text']}</strong></label>
					<input type='checkbox' id='showText' name='show_text' value='1' class='input_check' {$checked}/>
<script type='text/javascript'>
$('showText').observe('click',function(){
	updateEffect();
});
</script>
				</li>

EOF;
		}
		if($this->itemSettings['add_remove'] == 'add' && $this->itemSettings['effect'] =='dropshadow')
		{
			$checked = $editing[$this->itemSettings['effect']]['drop_background'] ? "checked='checked' " : "";
			$html .= <<<EOF
				<li>
					<label><strong>{$this->lang->words['shadow_offset']}</strong></label>
					<input type='button' id='offsetL' value='&larr;' class='input_submit' />
					<input type='button' id='offsetU' value='&uarr;' class='input_submit' />
					<input type='button' id='offsetD' value='&darr;' class='input_submit' />
					<input type='button' id='offsetR' value='&rarr;' class='input_submit' />
					<input type='hidden' name='x_offset' id='xOffset' value='{$editing[$this->itemSettings['effect']]['offx']}' />
					<input type='hidden' name='y_offset' id='yOffset' value='{$editing[$this->itemSettings['effect']]['offy']}' />
				</li>
				<li>
					<label><strong>{$this->lang->words['show_dropshadow_background']}</strong></label>
					<input type='checkbox' id='dropBackground' name='drop_background' value='1' class='input_check' {$checked}/>
				</li>
<script type='text/javascript'>
$('offsetL').observe('click',function(){
	$('xOffset').setValue(parseInt($('xOffset').getValue()) - 1);
	updateEffect();
});
$('offsetR').observe('click',function(){
	$('xOffset').setValue(parseInt($('xOffset').getValue()) + 1);
	updateEffect();
});
$('offsetU').observe('click',function(){
	$('yOffset').setValue(parseInt($('yOffset').getValue()) - 1);
	updateEffect();
});
$('offsetD').observe('click',function(){
	$('yOffset').setValue(parseInt($('yOffset').getValue()) + 1);
	updateEffect();
});
$('dropBackground').observe('click',function(){
	updateEffect();
});
</script>

EOF;
		}
		
		$preview = $this->itemSettings['add_remove'] == 'add' ? "<input type='button' value='{$this->lang->words['preview']}' class='input_text' id='previewButton' />" : "";
		$html .= <<<EOF
				<li>
					<label><strong>{$this->lang->words['preview']}</strong></label>
					{$preview}
					<br />
					<div class='post_block hentry clear'>
						<div class='post_wrap'>
							<h3>
								{$this->registry->getClass('output')->getReplacement("user_online")}
								<span class="author vcard"><a class="url fn" href='{$this->settings['base_url']}showuser={$this->memberData['member_id']}'>{$_prefix}{$prefix}{$this->memberData['members_display_name']}{$suffix}{$_suffix}</a>{$this->registry->getClass('output')->getTemplate('global')->user_popup($this->memberData['member_id'], $this->memberData['members_seo_name'])}</span>
							</h3>
						</div>
					</div>
				</li>
			</ul>
		</fieldset>
		<fieldset class="submit">
			<input class="input_submit" type="submit" value="{$this->lang->words['apply_name_effect']}" name="submit" />
		</fieldset>
	</div>
</form>
<script type='text/javascript'>
$('previewButton').observe('click',function(){
	updateEffect();
});
function updateEffect()
{
	switch('{$this->itemSettings['effect']}')
	{
		case 'color':
			$('currentEffect').setStyle({
				color: $('color').getValue()
			});
			break;
		case 'background':
			$('currentEffect').setStyle({
				backgroundColor: $('color').getValue()
			});
			break;
		case 'blur':
			$('currentEffect').setStyle({
				filter: 'blur(add='+(!$('showText').checked)+', direction='+$('direction').getValue()+', strength='+$('strength').getValue()+')'
			});
			break;
		case 'wave':
			$('currentEffect').setStyle({
				filter: 'wave(strength='+$('strength').getValue()+')'
			});
			break;
		case 'dropshadow':
			$('currentEffect').setStyle({
				filter: 'dropshadow(color='+$('color').getValue()+', offx='+$('xOffset').getValue()+', offy='+$('yOffset').getValue()+', Positive='+(!$('dropBackground').checked)+')'
			});
			break;
		case 'shadow':
			$('currentEffect').setStyle({
				filter: 'shadow(color='+$('color').getValue()+', direction='+$('direction').getValue()+')'
			});
			break;
		case 'glow':
			$('currentEffect').setStyle({
				filter: 'glow(color='+$('color').getValue()+', strength='+$('strength').getValue()+')'
			});
			break;
	}
}
</script>

EOF;
		return $html;
	}
	
	/**
	 * Any AJAX functionality
	 *
	 * @access	public
	 * @param	array	$invItem		The inventory item
	 * @return	void
	 */
	public function publicAjax(array &$invItem)
	{
		return;
	}
	
	/**
	 * When the item is being sold back
	 *
	 * @access	public
	 * @param	array	&$invItem	The inventory item information
	 * @return	bool				true if successful, false otherwise
	 */
	public function publicOnResoldItem(array &$invItem)
	{
		return true;
	}
	
	/**
	 * When the item is being restocked
	 *
	 * @access	public
	 * @param	array	&$item	The inventory item information
	 * @return	void
	 */
	public function onItemRestock(array &$item)
	{
		return;
	}
}
